package yanc.app


class LoginInterceptor {
    LoginInterceptor() {
//        match(controller: "menu")
        match(controller: "user").excludes(action: "vali")
                .excludes(action: "getCode")
                .excludes(action: "checkCode")
                .excludes(action: "loginout").excludes(action: "auth").excludes(action: "syncuser").excludes(action: "deluser")
        match(controller: "roles")
        match(controller: "types")
        match(controller: "news").excludes(action: "getNews")
        match(controller: "feedback").excludes(action: "index").excludes(action: "add")
        match(controller: "payOrder")
        match(controller: "phone")
        match(controller: "business").excludes(action: "getCom")
        match(controller: "version").excludes(action: "download").excludes(action: "filedownload")
    }


    boolean before() {
        println "进入拦截器"
        println session.user
        println session.id
        if (session.user == null) {
            redirect(url: '/')
            return false
        } else {
            session.setMaxInactiveInterval(3000 * 60)
            return true
        }
    }

    boolean after() { true }
}
